import tkinter as tk
import maze as maze
import micromouse as micromouse

root = tk.Tk()
windows_w = 640*2+100
windows_h = 640
bd = 10
map_size = 32
win = [15, 15]
root.title("MicroMouse")
root.geometry("{}x{}".format(windows_w, windows_h))


cv = tk.Canvas(root, width=windows_h*2, height=windows_h, bg='white')
cv.place(x=0, y=0)


mz = maze.Maze(cv, windows_h, bd, win, map_size)
mz.draw_maze()
mz.draw_win_point()

mouse = micromouse.MicroMouse(cv, mz.cell_len, bd, win, windows_h, map_size)
mouse.draw_mouse(0, 0)
mouse.draw_win_oval()
mouse.draw_search_maze()

save = tk.Button(root, text='保存迷宫', command=mz.save_maze, height=1, width=8)
save.place(x=windows_h*2+20, y=10)

open = tk.Button(root, text='加载迷宫', command=mz.load_maze, height=1, width=8)
open.place(x=windows_h*2+20, y=50)

search = tk.Button(root, text='探索迷宫', command=lambda mz=mz: mouse.search_maze(mz), height=1, width=8)
search.place(x=windows_h*2+20, y=90)

setmouse = tk.Button(root, text='重置电脑鼠', command=mouse.reset_mouse, height=1, width=8)
setmouse.place(x=windows_h*2+20, y=130)

root.mainloop()

